<template>
	<view style="width: 100%;height: 100%;" :style="{'border-radius': radius}">
		<video :muted="muted" v-show="video && enter" :id="`gv_${id}`" webkit-playsinline='true' playsinline='true' 
			style="width: 100%;height: 100%;border-right: 1rpx solid #e0e5fa;" :style="{'border-radius': radius}" autoplay object-fit="cover"></video>
		<image v-if="video && enter && !audio" src="/static/images/dfab.png" style="width: 50rpx;position: relative;bottom:70rpx;left: 10rpx;" mode="widthFix"></image>
		<view v-if="!enter"
			style="width: 100%;height: 100%;display: flex;flex-direction: column;align-items: center;background: #2b2b2b;color: #e0e5fa;">
		
			<view style="margin-top: 140rpx;font-size: 35rpx;">
				<u-avatar :src="$store.state.common.systemInfo.fileurl + 'avatar/' + uid + '.jpg'"></u-avatar>
			</view>
			<view style="margin-top: 20rpx;font-size: 30rpx;">
				{{name}}
			</view>
		
			<view style="display: flex;justify-content: center;align-items: center;margin-top: 50rpx;">
				<image src="/static/images/ddjr.png" style="width: 60rpx;height: 60rpx;" mode=""></image>
			</view>
		</view>
		<view v-if="enter && !video"
			style="width: 100%;height: 100%;display: flex;flex-direction: column;align-items: center;background: #333;color: #e0e5fa;">
		
			<view style="margin-top: 40%;font-size: 35rpx;">
				<u-avatar :src="$store.state.common.systemInfo.fileurl + 'avatar/' + uid + '.jpg'"></u-avatar>
			</view>
			<view style="margin-top: 20rpx;font-size: 30rpx;">
				{{name}}
			</view>
		
			<view style="display: flex;justify-content: center;align-items: center;margin-top: 50rpx;">
				<view v-if="audio"
					style="width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfaa.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
				<view v-if="!audio"
					style="width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfab.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
				<view v-if="!video"
					style="margin-left: 2rpx; width: 40rpx;height: 40rpx;display: flex;justify-content: center;align-items: center;border-radius: 60rpx;">
					<image src="/static/images/dfccamerb.png" style="width: 30rpx;" mode="widthFix"></image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
import { sub } from '../../../common/event';
	export default {
		data() {
			return {

			}
		},
		props: {
			id: {
				type: String | Number,
				default: ''
			},
			k: {
				type: String | Number,
				default: ''
			},
			mid: {
				type: String | Number,
				default: ''
			},
			uid: {
				type: String | Number,
				default: '17'
			},
			name: {
				type: String | Number,
				default: ''
			},
			radius: {
				type: String | Number,
				default: '0rpx'
			},
			src: {
				type: MediaStream,
			},
			status: {
				type: String,
				default: 'play'
			},
			muted: {
				type: Boolean,
				default: false
			},
			enter: {
				type: Boolean,
				default: false
			},
			video: {
				type: Boolean,
				default: false
			},
			audio: {
				type: Boolean,
				default: false
			}
		},
		watch: {
			src: function(v) {
				if (v && v.id) {
					const content = document.getElementById(`gv_${this.id}`);
					const items = content.getElementsByTagName("video");
					if (items && items.length > 0) {
						items[0].srcObject = v
					}
				}
			}
		},
		mounted() {
			sub("gvideoitemstreamdone_" + this.mid + "_" + this.uid,(e)=>{
				const content = document.getElementById(`gv_${this.id}`);
				const items = content.getElementsByTagName("video");
				if (items && items.length > 0) {
					items[0].srcObject = e.stream
				}
			})
			
			
		}
	}
</script>

<style>
</style>